<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>编辑应用负载</title>
    <link rel="stylesheet" type="text/css" href="../../js/layer/css/layui.css">
    <style>
        .zhanshop-form-label{
            float: left;
            width: 100%;
            text-align: left;
            line-height: 2.2em;
            color: #4d5259;
        }
        .text-pink{
            color: #f00;
        }
        .zhanshop-select{
            height: 38px;
            width: 100%;
            padding-left: 10px;
            padding-right: 10px;
            background: #fff;
            border: 1px solid #dddddd;
        }
        .layui-table{
            text-align: left;
        }
    </style>
</head>
<body>

<form class="layui-form" id="view">
    <input id="domain" type="hidden" name="domain" value="{{d.domain}}">
    <div class="layui-tab layui-tab-brief" lay-filter="test-hash" style="text-align: center !important; position: relative;">
        <ul class="layui-tab-title" id="step-title" style="display: none;">
            <li class="layui-this" id="layui-tab0" lay-id="11">基础信息</li>
        </ul>
        <div style="height: 40px; width: 100%; position: absolute; top: 0px;"></div>
        <div class="layui-tab-content" style="padding-left: 10px; padding-right: 10px;">
            <div class="layui-tab-item layui-show">
                <div class="demo-reg-container">

                    <div class="layui-form-item">
                        <label class="zhanshop-form-label"><b class="text-pink"></b>证书内容（PEM 格式）</label>
                        <div class="layui-input-wrap">
                            <textarea id="certificate" name="certificate" placeholder="PEM 格式的证书文件常见扩展名为 .crt、.pem、.cer, 请将证书内容（包含证书链）复制粘贴到此处" autocomplete="off" class="layui-textarea" >{{d.certificate}}</textarea>
                        </div>
                    </div>

                    <div class="layui-form-item">
                        <label class="zhanshop-form-label"><b class="text-pink"></b>证书私钥（PEM 格式）</label>
                        <div class="layui-input-wrap">
                            <textarea id="private_key" name="private_key" value="" placeholder="PEM 格式私钥文件常见扩展名为 .key、.pem, 请将私钥内容复制粘贴到此处" autocomplete="off" class="layui-textarea" >{{d.private_key}}</textarea>
                        </div>
                    </div>

                    <div class="layui-form-item">
                        <button type="button" lay-submit lay-filter="from-submit" class="layui-btn layui-btn-sm">确&nbsp;&nbsp;&nbsp;认</button>
                    </div>
                </div>
            </div>

        </div>
    </div>
</form>



<!-- 请勿在项目正式环境中引用该 layui.js 地址 -->
<script src="../../js/layer/layui.js"></script>
<script>
    ready(function() {
        layui.use(['zhanshop'], function(){
            $ = layui.$;
            zhanshop = layui.zhanshop;
            form = layui.form;
            var menuId = 'Cloudlvs';//parent.layui.zhanshop.getParam('_id');

            layui.zhanshop.view(API_ADDRESS+apiUrlTable+'/'+menuId+'?pk'+'='+layui.zhanshop.getParam('domain'), '#view', function(data){
                form.render(); // 渲染全部表单
            }, 'POST', {'_method': 'certfrom'});

            // 提交事件

            form.on('submit(from-submit)', function(data){

                var submitData = data.field; // 获取表单字段值
                submitData['_method'] = 'savecert';
                // 我这里不要走json了
                layui.zhanshop.ajax(API_ADDRESS+apiUrlTable+'/'+menuId, 'POST', submitData, {}, function(res){
                    return layui.zhanshop.alert('操作成功', 'success', function(){
                        parent.window.location.reload();
                    });
                },function(xhr){
                    return layui.zhanshop.alert(xhr.responseJSON.msg ? xhr.responseJSON.msg : xhr.statusText, 'danger');
                }, true, apiFromJson);
                return false; // 阻止默认 form 跳转

            });
        });
    });
</script>

</body>
</html>